{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Applying a pretrained pipeline\n",
    "\n",
    "In this tutorial, you will learn how to apply `pyannote.audio` pipelines on an audio file.\n",
    "\n",
    "A pipeline takes an audio file as input and returns a labeled temporal segmentation of the audio file. \n",
    "\n",
    "More precisely, it usually applies a pretrained model (= neural network) on the audio file, post-processes the output of the model, and returns its output as a [`pyannote.core.Annotation`](http://pyannote.github.io/pyannote-core/structure.html#annotation) instance. It should become clearer as you keep reading..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Loading pipeline from 🤗 hub\n",
    "\n",
    "Pretrained pipelines are available on [🤗 Huggingface model hub](https://hf.co/models?other=pyannote-audio-pipeline) and can be listed by looking for the [`pyannote-audio-pipeline`](https://hf.co/models?other=pyannote-audio-pipeline) tag."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['pyannote/speaker-diarization',\n",
       " 'pyannote/speaker-segmentation',\n",
       " 'pyannote/voice-activity-detection',\n",
       " 'pyannote/overlapped-speech-detection',\n",
       " 'philschmid/pyannote-speaker-diarization-endpoint']"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from huggingface_hub import HfApi\n",
    "available_pipelines = [p.modelId for p in HfApi().list_models(filter=\"pyannote-audio-pipeline\")]\n",
    "available_pipelines"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To load the speaker diarization pipeline,\n",
    "\n",
    "* accept the user conditions on [hf.co/pyannote/speaker-diarization](https://hf.co/pyannote/speaker-diarization).\n",
    "* login using `notebook_login` below"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Login successful\n",
      "Your token has been saved to /Users/hbredin/.huggingface/token\n",
      "\u001b[1m\u001b[31mAuthenticated through git-credential store but this isn't the helper defined on your machine.\n",
      "You might have to re-authenticate when pushing to the Hugging Face Hub. Run the following command in your terminal in case you want to set this credential helper as the default\n",
      "\n",
      "git config --global credential.helper store\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "from huggingface_hub import notebook_login\n",
    "notebook_login()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyannote.audio import Pipeline\n",
    "pipeline = Pipeline.from_pretrained(\"pyannote/speaker-diarization@develop\", use_auth_token=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Processing a file from disk"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "... and apply it to an audio file.  \n",
    "\n",
    "The pipeline will automatically use GPUs when available. \n",
    "On CPU it might take a long while (up to 10x RT)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ROOT_DIR = \"/Users/hbredin/Development/pyannote/pyannote-audio\"\n",
    "AUDIO_FILE = f\"{ROOT_DIR}/tutorials/assets/sample.wav\"\n",
    "dia = pipeline(AUDIO_FILE)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Visualizing the output\n",
    "\n",
    "Most pipelines return a [`pyannote.core.Annotation`](http://pyannote.github.io/pyannote-core/structure.html#annotation) instance..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyannote.core import Annotation\n",
    "assert isinstance(dia, Annotation)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "... whose [API](https://pyannote.github.io/pyannote-core/structure.html#annotation) you can use to print the result:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " 6.7  7.1 SPEAKER_02\n",
      " 6.9  8.3 SPEAKER_00\n",
      " 8.3 14.8 SPEAKER_02\n",
      " 9.8 11.0 SPEAKER_00\n",
      "14.3 18.5 SPEAKER_01\n",
      "17.9 21.5 SPEAKER_02\n",
      "21.7 28.6 SPEAKER_01\n",
      "27.8 29.5 SPEAKER_02\n"
     ]
    }
   ],
   "source": [
    "for speech_turn, track, speaker in dia.itertracks(yield_label=True):\n",
    "    print(f\"{speech_turn.start:4.1f} {speech_turn.end:4.1f} {speaker}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you happen to be running this example in a _Jupyter notebook_, `dia` can be [visualized directly](http://pyannote.github.io/pyannote-core/visualization.html):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABi8AAADyCAYAAAA1MlYeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy89olMNAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAecUlEQVR4nO3de5DV5X0/8M9hhQXcCyxkucjFrReEIHYAB9HUiB1QmvgDY1s0xkBNMzIFJ5SpSYqpkmilpqNO+7MyuSjIb1SYDgGZJprQKLeorVCptDo0JjCQKKwusLAoIPD9/eG4zbrLZZfDnmf3vF4zZ4bzPd/zPJ/znWef83De53y/uSzLsgAAAAAAAEhEl0IXAAAAAAAA8LuEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKEFwAAAAAAQFKKMryora2NO+64I4YMGRKlpaXRv3//uO666+Lll1+OiIjzzz8/crlc5HK56NmzZ4wcOTK+973vNT5/8eLFjY//7q179+7N+nrppZeipKQkrr/++maPbd++PXK5XGzevLlx24EDB+Kaa66JSy65JHbu3BkR0WJfuVwuli5dGhERa9asabK9T58+ce2118YvfvGLVh2X5cuXx4gRI6K0tDRGjBgRK1asaLbPY489FjU1NdG9e/cYM2ZMrF+/vlV9FBtjrWWnGmvr1q2LG264IQYOHBi5XC5WrlzZqvaLjXHWslONswULFsTll18e5eXlUV1dHVOnTo2tW7e2qg8AAAAAzo5z8t3g3oNH8t3kSfU+t1urn3PTTTfFhx9+GE8++WT83u/9XuzevTt+/vOfx549exr3+c53vhNf/epXo6GhIRYvXhwzZ86MXr16xbRp0yIioqKiotmHXLlcrllfTzzxRNx5553xwx/+MHbs2BFDhgw5YV3vvvtuTJ48OSIiNmzYEH379m18bNGiRc0+LOzVq1eT+1u3bo2Kiop499134/7774/Pfe5z8T//8z9RXV19ymPy8ssvx7Rp0+K+++6LG2+8MVasWBF/+qd/Ghs2bIhx48ZFRMSyZctizpw58dhjj8VVV10V3/ve92Ly5MnxxhtvnPR1nS31h+vbtb/K0spWP8dYa+50xtrBgwfjsssuiz/7sz+Lm2666ZRtnm3H6urara+SPn1a/RzjrLnTGWdr166NWbNmxeWXXx5Hjx6Nu+++OyZNmhRvvPFGnHvuuafsAwAAAICzJ5dlWZbPBq+496f5bO6UXvn2da3af9++fdG7d+9Ys2ZNfPazn21xn/PPPz/mzJkTc+bMadx28cUXx5gxY+KZZ56JxYsXx5w5c2Lfvn0n7evgwYMxYMCAePXVV+Pee++NESNGxD333NP4+Pbt26OmpiZee+216NOnT0ycODEGDBgQq1ativLy8sb9crlcrFixIqZOndpiP2vWrIkJEybE3r17Gz/827JlS4waNSpWrVoVN9xwwymPy7Rp02L//v3x3HPPNW67/vrro3fv3vHMM89ERMS4ceNi9OjRsXDhwsZ9hg8fHlOnTo0FCxacso98+z8rP9eu/a2a+uNW7W+stex0xtrvOlVN7eG35w1ut77O++3OVu1vnLWsteMs4qOwpbq6OtauXRtXX331KfsAAAAA4OwputNGlZWVRVlZWaxcuTIOHz582s/r3r17fPjhh63qa9myZTFs2LAYNmxYfOlLX4pFixZFS1nR1q1b46qrropLLrkknn/++SYf8rXF+++/H4sWLYqIiK5du57Wc15++eWYNGlSk23XXXddvPTSSxERceTIkdi0aVOzfSZNmtS4D00Zay071VijdYyzlrVlnNXXf/RrrqqqqjZWCgAAAEC+FF14cc4558TixYvjySefjF69esVVV10V8+bNi9dff73F/Y8ePRqLFy+OLVu2xB/+4R82bq+vr2/80PDj2yc/KHv88cfjS1/6UkR89I3fhoaG+PnPf96sjy9/+ctxwQUXxPLly6O0tLTFOm655ZZm/f36179uss+gQYMaH3vkkUdizJgxTWo+mV27dkW/fv2abOvXr1/s2rUrIiLee++9OHbs2En3oSljrWWnGmu0jnHWstaOsyzLYu7cufGZz3wmRo4ceVp9AAAAAHD2FF14EfHR+eHffvvtWLVqVVx33XWxZs2aGD16dCxevLhxn2984xtRVlYWPXr0iFmzZsVdd90Vd9xxR+Pj5eXlsXnz5ia3j78ZHPHRN4///d//PW6++eaI+OgDxmnTpsUTTzzRrJ4pU6bEhg0bYvny5Ses+ZFHHmnW3+DBTU9ls379+viP//iPeOaZZ2Lo0KGxePHi0/6WckTz89tnWdZs2+nsw/8y1lpmHOWXcday1oyz2bNnx+uvv37CU0oBAAAA0L7yfsHu574+Id9NnhXdu3ePiRMnxsSJE+Oee+6JP//zP4977703ZsyYERERd911V8yYMSN69uwZAwYMaPaBV5cuXeLCCy88YfuPP/54HD16NM4777zGbVmWRdeuXWPv3r3Ru3fvxu3z5s2LUaNGxa233hpZljVeQPd39e/f/6T9RUTU1NREr1694uKLL45Dhw7FjTfeGP/1X/91wm8+f7L9T34juba2tvGby3379o2SkpKT7tPe/t/kpwvSb2sZa83bT2kcnY7+r28udAmnZJw1b/90x9mdd94Zq1atinXr1sWgQYNO2TYAAAAAZ1/ef3nR+9xu7XrLlxEjRsTBgwcb7/ft2zcuvPDCGDhwYKu/EX706NFYsmRJPPTQQ02+Vfyf//mfMXTo0HjqqaeaPedb3/pW3HfffXHrrb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AAAICObf/+/TF48ODG/OBMtDm8+PhUURUVFcILAAAAAAAgIiIvl5pwwW4AAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwgsAAAAAACApwguARB3bvTv2P/RwHNu9u0O0m6pie70AZ8q8SWqMSTqz1ozvPYf2xNNvPhV7Du1ph8oAOBHzcfsRXgAk6lhtbRx4+JE4VlvbIdpNVbG9XoAzZd4kNcYknVlrxvfeQ3ti6danY68PywAKynzcfoQXAAAAAABAUoQXAAAAAABAUoQXAAAAAABAUs4pdAEAnNzxffVxrK4ur+0Vo3wfR4DOqljfJ0if93I6o7bMuQ1HGqL+sLkaoFAajjQUuoSiIbwASFzdzbcUuoROwXEEgI7Nezl85G9eurvQJQBAu3DaKAAAAAAAICnCCwAAAAAAICnCCwAAAAAAICmueQGQuD5Ln4muI4bnrb0P33izKM8Zne/jCNBZFev7BOnzXk5n1JY5974r/zbOr6w5SxUBcCrb67e5/lA7EV4AJK5Lr8oo6dMnb+0d61WZt7Y6knwfR4DOqljfJ0if93I6o7bMuWXdyqKy1FwNUChl3coKXULRcNooAAAAAAAgKcILAAAAAAAgKcILAAAAAAAgKcILAAAAAAAgKcILgESVVFdH+dy/jJLq6g7RbqqK7fUCnCnzJqkxJunMWjO+e3evipuHfTF6d69qh8oAOBHzcfvJZVmWteWJ+/fvj8rKyqivr4+Kiop81wUAAAAAAHQg+cwN/PICAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACAAAAAABIivACoBN578Dh+MGLb8V7Bw4XupRkOCZtV8zHrphfO+nac2hPPP3mU7Hn0J5ClwJFwd8cALSPY7t3x/6HHo5ju3cXupROqSMfX+EFQCfy3oHD8fiaX/nA9Xc4Jm1XzMeumF876dp7aE8s3fp07PVBKrQLf3MA0D6O1dbGgYcfiWO1tYUupVPqyMdXeAEAAAAAACRFeAEAAAAAACTlnEIXAED+Hfjgw9h78Eihy0jCgQ8+LHQJHV4xjifjhpQ1HGmI+sP1hS4DOr2GIw2FLgEAisrxffVxrK6u0GV0Osf3ddz/OwgvADqhO5dsLHQJdCLGE6Tlb166u9AlAABA3tXdfEuhSyAxThsFAAAAAAAkRXgBAAAAAAAkRXgBAAAAAAAkxTUvADqh//vlsXFh//JCl5GEt3YdcM2GM1SM48m4IWX3Xfm3cX5lTaHLgE5ve/0215gBgHbUZ+kz0XXE8EKX0el8+MabHfZ6IsILgE6ovEfX6H1ut0KXkYTyHl0LXUKHV4zjybghZWXdyqKytLLQZUCnV9atrNAlAEBR6dKrMkr69Cl0GZ3OsV4d9/8OThsFAAAAAAAkRXgBAAAAAAAkRXgBAAAAAAAkRXgBAAAAAAAkRXgB0In0LS+Nr1xzQfQtLy10KclwTNqumI9dMb920tW7e1XcPOyL0bt7VaFLgaLgbw4A2kdJdXWUz/3LKKmuLnQpnVJHP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Vsbt/Xo0SMqKysLURoAAFCknDYKAACKXP/+/RtvlZWVkcvlmm375GmjZsyYEVOnTo0HHngg+vXrF7169Ypvf/vbcfTo0bjrrruiqqoqBg0aFE888USTvn7729/GtGnTonfv3tGnT5+YMmVKbN++vX1fMAAAkDzhBQAA0CYvvPBCvP3227Fu3bp4+OGHY/78+fH5z38+evfuHf/2b/8WM2fOjJkzZ8bOnTsjIuL999+PCRMmRFlZWaxbty42bNgQZWVlcf3118eRI0cK/GoAAICUCC8AAIA2qaqqin/8x3+MYcOGxe233x7Dhg2L999/P+bNmxcXXXRR/PVf/3V069YtfvGLX0RExNKlS6NLly7xwx/+MC699NIYPnx4LFq0KHbs2BFr1qwp7IsBAACSck6hCwAAADqmT3/609Gly/9+H6pfv34xcuTIxvslJSXRp0+fqK2tjYiITZs2xVtvvRXl5eVN2jl06FD86le/ap+iAQCADkF4AQAAtEnXrl2b3M/lci1uO378eEREHD9+PMaMGRNPPfVUs7Y+9alPnb1CAQCADkd4AQAAtIvRo0fHsmXLorq6OioqKgpdDgAAkDDXvAAAANrFrbfeGn379o0pU6bE+vXrY9u2bbF27dr42te+Fr/5zW8KXR4AAJAQ4QUAANAuevbsGevWrYshQ4bEF77whRg+fHjcfvvt8cEHH/glBgAA0EQuy7Ks0EUAAAAAAAB8zC8vAAAAAACApAgvAAAAAACApAgvAAAAAACApAgvAAAAAACApAgvAAAAAACApAgvAAAAAACApAgvAAAAAACApAgvAAAAAACApAgvAAAAAACApAgvAAAAAACApAgvAAAAAACApPx/5IKCZzhkmCsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<pyannote.core.annotation.Annotation>"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# we visualize [0, 30] time range\n",
    "from pyannote.core import notebook, Segment\n",
    "notebook.crop = Segment(0, 30)\n",
    "dia"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When available, the reference annotation can be visualized too, for comparison:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABi8AAADyCAYAAAA1MlYeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy89olMNAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAdaElEQVR4nO3dfYxU1f0/8M+wwALuA+zi8iAPUh9QRGxEo6i1agNCqz9Q26JVC7U1kqKRklot+lVq/Uq1UdPGaNqqoN+okIaCpFWrVQHxoRUrkbaGaoWAVVhdYGFRQOD+/jBuu+4iLMwyZ3dfr2QS5t6Zcz4zc+Zwdt4z9+ayLMsCAAAAAAAgER0KXQAAAAAAAMB/E14AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJEV4AAAAAAABJaZfhRXV1dVxxxRUxYMCAKC4ujt69e8fZZ58dL730UkREHHrooZHL5SKXy0W3bt1i6NCh8atf/ar+/rNmzarf/9+XLl26NOrrxRdfjKKiohg9enSjfatWrYpcLhfLli2r37Z58+Y444wz4qijjoo1a9ZERDTZVy6Xi9mzZ0dExMKFCxtsr6ysjLPOOiteeOGFZj0vc+fOjSFDhkRxcXEMGTIk5s2b12D/4sWL49xzz42+fftGLpeL+fPnN6v99shYa9qextqMGTPixBNPjNLS0qiqqopx48bFihUrmtUHAAAAANB6dcx3g7XbavPd5OcqLy5v9n0uuOCC+Pjjj+PBBx+ML3zhC7Fu3bp45plnYv369fW3ufnmm+Pyyy+Purq6mDVrVkyaNCm6d+8e48ePj4iIsrKyRh+m5nK5Rn098MADcdVVV8V9990Xq1evjgEDBuy2rvfffz/GjBkTERFLliyJnj171u+bOXNmow+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EAAAAAALQNNTU1UV5evl9t7HN4UVFRERERq1ev3u8igNZp06ZN0b9//1izZk2UlZUVuhygQMwFgHkAMA8AEeYCIKK2tjYGDBhQnx/sj30OLzp0+OR0GeXl5SYjaOfKysrMA4C5ADAPAOYBICLMBcB/8oP9aiMPdQAAAAAAAOSN8AIAAAAAAEjKPocXxcXFcdNNN0VxcXE+6wFaEfMAEGEuAMwDgHkA+IS5AMjnPJDLsizLQ00AAAAAAAB54bBRAAAAAABAUoQXAAAAAABAUoQXAAAAAABAUoQXAAAAAABAUvYpvLjnnnti0KBB0aVLlxg+fHg8//zz+a4LSNj06dMjl8s1uPTu3bvQZQEtaPHixXHuuedG3759I5fLxfz58xvsz7Ispk+fHn379o2uXbvGGWecEX//+98LUyzQYvY0F0ycOLHRGuHkk08uTLFA3s2YMSNOPPHEKC0tjaqqqhg3blysWLGiwW2sCaDt25u5wJoA2rZ77703hg0bFmVlZVFWVhYjRoyIJ554on5/vtYDzQ4v5syZE1OmTInrr78+XnvttfjSl74UY8aMidWrVze7c6D1OuaYY+K9996rvyxfvrzQJQEtaMuWLXHcccfF3Xff3eT+22+/Pe688864++6745VXXonevXvHyJEjY/PmzQe4UqAl7WkuiIgYPXp0gzXC448/fgArBFrSokWLYvLkyfHyyy/H008/HTt27IhRo0bFli1b6m9jTQBt397MBRHWBNCW9evXL372s5/F0qVLY+nSpXHWWWfF2LFj6wOKfK0HclmWZc25w0knnRTHH3983HvvvfXbjj766Bg3blzMmDGjWZ0DrdP06dNj/vz5sWzZskKXAhRALpeLefPmxbhx4yLik29U9O3bN6ZMmRLXXnttRERs27YtevXqFbfddltcccUVBawWaCmfnQsiPvmW5caNGxv9IgNom95///2oqqqKRYsWxemnn25NAO3UZ+eCCGsCaI8qKiri5z//eVx22WV5Ww8065cX27dvj1dffTVGjRrVYPuoUaPixRdfbE5TQCv35ptvRt++fWPQoEFx4YUXxttvv13okoACWblyZaxdu7bB+qC4uDi+/OUvWx9AO7Rw4cKoqqqKI488Mi6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liiy+Onj17xtixY+P555+PlStXxqJFi+Lqq6+Od955p9DlAQAACRFeAAAAB0S3bt1i8eLFMWDAgDj//PPj6KOPjssuuyw++ugjv8QAAAAayGVZlhW6CAAAAAAAgE/55QUAAAAAAJAU4QUAAAAAAJAU4QUAAAAAAJAU4QUAAAAAAJAU4QUAAAAAAJAU4QUAAAAAAJAU4QUAAAAAAJAU4QUAAAAAAJAU4QUAAAAAAJAU4QUAAAAAAJAU4QUAAAAAAJCU/w8kZhcpsgfzZgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<pyannote.core.annotation.Annotation>"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyannote.database.util import load_rttm\n",
    "REFERENCE = f\"{ROOT_DIR}/tutorials/assets/sample.rttm\"\n",
    "reference = load_rttm(REFERENCE)[\"sample\"]\n",
    "\n",
    "# map hypothesized and reference speakers for visualization purposes\n",
    "pipeline.optimal_mapping(dia, reference)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Processing a file from memory\n",
    "\n",
    "In case the audio file is not stored on disk, pipelines can also process audio provided as a `{\"waveform\": ..., \"sample_rate\": ...}` dictionary. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "type(waveform)=<class 'torch.Tensor'>\n",
      "waveform.shape=torch.Size([1, 480000])\n",
      "waveform.dtype=torch.float32\n"
     ]
    }
   ],
   "source": [
    "import torchaudio\n",
    "waveform, sample_rate = torchaudio.load(AUDIO_FILE)\n",
    "\n",
    "print(f\"{type(waveform)=}\")\n",
    "print(f\"{waveform.shape=}\")\n",
    "print(f\"{waveform.dtype=}\")\n",
    "\n",
    "audio_in_memory = {\"waveform\": waveform, \"sample_rate\": sample_rate}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABi8AAADyCAYAAAA1MlYeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy89olMNAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAXJElEQVR4nO3dfZDVdd3/8ddB4k52F1eEhWEh8oZQ1EYtxG4UGxAqg+RyKL28ICZGJq0YJ3WiUjJHiiabGiemchKdsR/Yr6TGDHMybkxtxOQn06Sp6YAJEiisgq135/eH416tmLpw1v3s7uMxszN7vufs93wOc+bDe/a555xKtVqtBgAAAAAAoBB9unoBAAAAAAAA/068AAAAAAAAiiJeAAAAAAAARREvAAAAAACAoogXAAAAAABAUcQLAAAAAACgKOIFAAAAAABQFPECAAAAAAAoingBAAAAAAAURbwAAAAAAACKIl4AAAAAAABFES8AAAAAAICiiBcAAAAAAEBRxAsAAAAAAKAo4gUAAAAAAFAU8QIAAAAAAChKr4wX27dvz/nnn5/Ro0enf//+aWpqyhlnnJG77747SfLud787lUollUolgwYNyoQJE/KjH/2o7eeXL1/edv2/fw0YMKDtNnPnzn3D20ybNq3dWu6///6cffbZGT58eAYMGJCjjjoq8+fPz9/+9rckyeOPP55KpZKNGzfu8zhOO+20LFy4sPb/QAAAAAAA0IX61vqEz+/+V61P+aYGNgx46xu9zqxZs/Liiy/m+uuvz3ve85489dRT+f3vf5+nn3667TZXXHFF5s+fn+eeey7Lly/PggULMmTIkMyePTtJUl9fn4ceeqjdeSuVSrvL06ZNy3XXXdfuWP/+/du+v+WWWzJr1qycccYZufHGG3P44Ydn+/bt+fnPf56vf/3rWblyZYcfGwAAAAAAdHc1jxc3/M//rfUp39T5v/rvDt1+165dufPOO7NmzZqceuqpSZIxY8bkAx/4QLvb1dXVpampKUly5ZVX5qabbsqqVava4kWlUmm7/j957VUdb2Tv3r357Gc/m4997GO5+eab246PHTs2EydOzK5duzr0uAAAAAAAoKfodW8bNXjw4AwePDirVq1Ka2vr2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GbMmJH169fnsccey9q1a/OlL30pTzzxRFcvDwAAKIh4AQAAvCMGDRqUdevWZfTo0TnrrLMyfvz4zJs3L88//7xXYgAAAO1UqtVqtasXAQAAAAAA8BqvvAAAAAAAAIoiXgAAAAAAAEURLwAAAAAAgKKIFwAAAAAAQFHECwAAAAAAoCjiBQAAAAAAUBTxAgAAAAAAKIp4AQAAAAAAFEW8AAAAAAAAiiJeAAAAAAAARREvAAAAAACAoogXAAAAAABAUf4/or9ACDkjvhcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<pyannote.core.annotation.Annotation>"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vad = Pipeline.from_pretrained(\"pyannote/voice-activity-detection\")\n",
    "vad(audio_in_memory)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
